//年-月-日-时:分:秒
function formatDate(value: any) {
    let timer: number = parseInt(value)
    let date = new Date(timer)
    let year: number = date.getFullYear()
    let month = date.getMonth() + 1
    month = month < 10 ? '0' + month : month
    let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
    let hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
    let fen = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
    let seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
    return `${year}-${month}-${day} ${hour}:${fen}:${seconds}`
}

// 分:秒
function formatSeconds(value: any) {
    var secondTime: any = parseInt(value);// 秒
    var minuteTime: any = 0;// 分
    var hourTime: any = 0;// 小时
    if (secondTime > 60) {//如果秒数大于60，将秒数转换成整数
        //获取分钟，除以60取整数，得到整数分钟
        minuteTime = parseInt(secondTime / 60);
        //获取秒数，秒数取佘，得到整数秒数
        secondTime = parseInt(secondTime % 60);
        //如果分钟大于60，将分钟转换成小时
        if (minuteTime > 60) {
            //获取小时，获取分钟除以60，得到整数小时
            hourTime = parseInt(minuteTime / 60);
            //获取小时后取佘的分，获取分钟除以60取佘的分
            minuteTime = parseInt(minuteTime % 60);
        }
    }
    var result = "" + parseInt(secondTime) + "";

    if (minuteTime > 0) {
        result = "" + parseInt(minuteTime) + ":" + result;
    }
    if (hourTime > 0) {
        result = "" + parseInt(hourTime) + ":" + result;
    }
    return result;
}
export default {
    formatDate,
    formatSeconds
}